/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.srcptit.trainning.giangnd.btvn2;

import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author GIANG
 */
public class try_catch {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int k=0,t=0;
        while(t==0){
            t=1;
            try {
                System.out.println("Nhap k");
                k=Integer.parseInt(sc.nextLine());
                if(k<0)
                    throw new Exception("Ban nhap so am xin moi nhap so duong");
            } catch (    NumberFormatException | NullPointerException e) {
                System.out.println(e);
                t=0;
            }
            catch (Exception ex) {
                System.out.println(ex);
                t=0;
            } 
        }
    }
}
